Add an internal child name for the notebook, so that GtkBuilder can be
authorMatthias Clasen <mclasen@redhat.com>
Fri, 7 Sep 2007 20:03:22 +0000 (20:03 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 7 Sep 2007 20:03:22 +0000 (20:03 +0000)
2007-09-07  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkprintunixdialog.c: Add an internal child name for
        the notebook, so that GtkBuilder can be used to add custom tabs.
        (#472951, Christian Persch)

svn path=/trunk/; revision=18757

ChangeLog
docs/reference/ChangeLog
docs/reference/gtk/tmpl/gtkprintunixdialog.sgml
gtk/gtkprintunixdialog.c

index a7f236d2d82bfa865fcf863194220103db1dc66d..259cfa2649b9de2c96c325163d58afbd09d78234 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-07  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkprintunixdialog.c: Add an internal child name for
+       the notebook, so that GtkBuilder can be used to add custom tabs.
+       (#472951, Christian Persch)
+
 2007-09-07  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/updateiconcache.c (get_image_meta_data_size): Don't
index d5065d2e6c7227e93ad2ae2a7620486fb394e29c..dc4ce0568fcf9dbf9fe32eec032bd5eb3f280597 100644 (file)
@@ -1,3 +1,7 @@
+2007-09-07  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/tmpl/gtkprintunixdialog.sgml: Additions
+
 2007-09-06  Matthias Clasen  <mclasen@redhat.com>
 
        * gdk-pixbuf/porting-from-imlib.sgml:
index 111a28b1bccc0853ea52c6db5f209107c6aee2bb..cc1dbacaf5a35c4203b3ca58530c1f27d7820d94 100644 (file)
@@ -39,6 +39,38 @@ gtk_print_job_new().
 Printing support was added in GTK+ 2.10.
 </para>
 
+<refsect2 id="GtkPrintUnixDialog-BUILDER-UI"><title>GtkPrintUnixDialog as GtkBuildable</title>
+<para>
+The GtkPrintUnixDialog implementation of the GtkBuildable interface exposes its
+@notebook internal children with the name "notebook".
+</para>
+<example>
+<title>A <structname>GtkPrintUnixDialog</structname> UI definition fragment.</title>
+<programlisting><![CDATA[
+<object class="GtkPrintUnixDialog" id="dialog1">
+  <child internal-child="notebook">
+    <object class="GtkNotebook" id="notebook">
+      <child>
+        <object class="GtkLabel" id="tabcontent">
+        <property name="label">Content on notebook tab</property>
+        </object>
+      </child>
+      <child type="tab">
+        <object class="GtkLabel" id="tablabel">
+          <property name="label">Tab label</property>
+        </object>
+        <packing>
+          <property name="tab_expand">False</property>
+          <property name="tab_fill">False</property>
+        </packing>
+      </child>
+    </object>
+  </child>
+</object>
+]]></programlisting>
+</example>
+</refsect2>
+
 <!-- ##### SECTION See_Also ##### -->
 <para>
 #GtkPageSetupUnixDialog, #GtkPrinter, #GtkPrintJob
index 66b65c8bdb00f50e099234a02379aa7a68c6fdb2..f5cc16809e50698f8cd26105c87563c6ac6e8a9c 100644 (file)
@@ -47,6 +47,7 @@
 #include "gtkalignment.h"
 #include "gtklabel.h"
 #include "gtkeventbox.h"
+#include "gtkbuildable.h"
 
 #include "gtkprintbackend.h"
 #include "gtkprinter-private.h"
@@ -91,6 +92,12 @@ static gboolean dialog_get_collate                 (GtkPrintUnixDialog *dialog);
 static gboolean dialog_get_reverse                 (GtkPrintUnixDialog *dialog);
 static gint     dialog_get_n_copies                (GtkPrintUnixDialog *dialog);
 
+/* GtkBuildable */
+static void gtk_print_unix_dialog_buildable_init                    (GtkBuildableIface *iface);
+static GObject *gtk_print_unix_dialog_buildable_get_internal_child  (GtkBuildable *buildable,
+                                                                     GtkBuilder   *builder,
+                                                                     const gchar  *childname);
+
 enum {
   PROP_0,
   PROP_PAGE_SETUP,
@@ -193,7 +200,11 @@ struct GtkPrintUnixDialogPrivate
   gint current_page;
 };
 
-G_DEFINE_TYPE (GtkPrintUnixDialog, gtk_print_unix_dialog, GTK_TYPE_DIALOG)
+G_DEFINE_TYPE_WITH_CODE (GtkPrintUnixDialog, gtk_print_unix_dialog, GTK_TYPE_DIALOG,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE,
+                                                gtk_print_unix_dialog_buildable_init))
+
+static GtkBuildableIface *parent_buildable_iface;
 
 static gboolean
 is_default_printer (GtkPrintUnixDialog *dialog,
@@ -390,6 +401,25 @@ printer_removed_cb (GtkPrintBackend    *backend,
   gtk_list_store_remove (GTK_LIST_STORE (priv->printer_list), iter);
 }
 
+static void
+gtk_print_unix_dialog_buildable_init (GtkBuildableIface *iface)
+{
+  parent_buildable_iface = g_type_interface_peek_parent (iface);
+
+  iface->get_internal_child = gtk_print_unix_dialog_buildable_get_internal_child;
+}
+
+static GObject *
+gtk_print_unix_dialog_buildable_get_internal_child (GtkBuildable *buildable,
+                                                    GtkBuilder   *builder,
+                                                    const gchar  *childname)
+{
+  if (strcmp (childname, "notebook") == 0)
+    return G_OBJECT (GTK_PRINT_UNIX_DIALOG (buildable)->priv->notebook);
+
+  return parent_buildable_iface->get_internal_child (buildable, builder, childname);
+}
+
 static void
 printer_status_cb (GtkPrintBackend    *backend, 
                   GtkPrinter         *printer,